# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("//bazel:pl_build_system.bzl", "pl_cc_library", "pl_cc_test")

package(default_visibility = ["//src:__subpackages__"])

pl_cc_library(
    name = "cc_library",
    srcs = glob(
        [
            "*.cc",
            "*.h",
        ],
        exclude = [
            "**/*_test.cc",
            "**/*_test_utils.h",
            "test_utils.h",
        ],
    ),
    hdrs = ["analyzer.h"],
    deps = [
        "//src/carnot/funcs/builtins:cc_library",
        "//src/carnot/planner/ast:cc_library",
        "//src/carnot/planner/compiler_error_context:cc_library",
        "//src/carnot/planner/compiler_state:cc_library",
        "//src/carnot/planner/ir:cc_library",
        "//src/carnot/planner/metadata:cc_library",
        "//src/carnot/planner/objects:cc_library",
        "//src/carnot/planner/parser:cc_library",
        "//src/carnot/planner/probes:cc_library",
        "//src/carnot/planner/rules:cc_library",
        "//src/carnot/udf:cc_library",
        "//src/shared/scriptspb:scripts_pl_cc_proto",
    ],
)

pl_cc_test(
    name = "analyzer_test",
    srcs = ["analyzer_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
    ],
)

pl_cc_test(
    name = "add_limit_to_batch_result_sink_rule_test",
    srcs = ["add_limit_to_batch_result_sink_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
    ],
)

pl_cc_test(
    name = "combine_consecutive_maps_rule_test",
    srcs = ["combine_consecutive_maps_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
    ],
)

pl_cc_test(
    name = "convert_metadata_rule_test",
    srcs = ["convert_metadata_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
    ],
)

pl_cc_test(
    name = "drop_to_map_rule_test",
    srcs = ["drop_to_map_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "restrict_columns_rule_test",
    srcs = ["restrict_columns_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
    ],
)

pl_cc_test(
    name = "merge_group_by_into_group_acceptor_rule_test",
    srcs = ["merge_group_by_into_group_acceptor_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "propagate_expression_annotations_rule_test",
    srcs = ["propagate_expression_annotations_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "remove_group_by_rule_test",
    srcs = ["remove_group_by_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "resolve_metadata_property_rule_test",
    srcs = ["resolve_metadata_property_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "resolve_stream_rule_test",
    srcs = ["resolve_stream_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "resolve_types_rule_test",
    srcs = ["resolve_types_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "setup_join_type_rule_test",
    srcs = ["setup_join_type_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "unique_sink_names_rule_test",
    srcs = ["unique_sink_names_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)

pl_cc_test(
    name = "verify_filter_expression_rule_test",
    srcs = ["verify_filter_expression_rule_test.cc"],
    deps = [
        ":cc_library",
        "//src/carnot/planner/compiler:test_utils",
        "//src/carnot/udf_exporter:cc_library",
    ],
)
